package pers.qianyu.diytomcat.classloader;

import java.io.*;
import java.net.*;

/**
 * @author mizzle rain
 * @date 2021-01-08 17:02
 */
public class CommonClassLoader extends URLClassLoader {
    public CommonClassLoader() {
        super(new URL[]{});
        try {
            String userDir = System.getProperty("user.dir");
            File lib = new File(userDir, "lib");
            for (File file : lib.listFiles()) {
                if (file.getName().endsWith(".jar")) {
                    this.addURL(new URL("file:" + file.getAbsolutePath()));
                }
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }
}
